import {Service} from "adajs";

const MAP = ["日", "一", "二", "三", "四", "五", "六"];

class CourseService extends Service {
    defaultData() {
        return {
            list: []
        }
    }

    onupdate(current, {list}) {
        current.list = list;
        current.list = current.list.map(item => {
            let a = item.jssj;
            let b = new Date(a.replace(/\-/g,"/"));
            let a1 = `${b.getFullYear()}-${b.getMonth() + 1}-${b.getDate()}`;
            let a2 = `星期${MAP[b.getDay()]}`;
            let a3 = `${b.getHours()}:${b.getMinutes()}`;
            return Object.assign({}, item, {
                year: a1,
                day: a2,
                time: a3
            });
        });
    }
}

export default CourseService;